using System.Linq.Expressions;

namespace CoreProject.IRepository
{
    public interface IBaseRepository<T>
    {
        /// <summary>
        /// 单条数据查询
        /// </summary>
        /// <param name="whereLambda"></param>
        /// <returns></returns>
        Task<T> GetAsync(Expression<Func<T, bool>> whereLambda);

        /// <summary>
        /// 全部数据查询
        /// </summary>
        /// <typeparam name="S"></typeparam>
        /// <param name="isAsc"></param>
        /// <param name="orderLambda"></param>
        /// <param name="whereLambda"></param>
        /// <returns></returns>
        Task<List<T>> GetListAsync<S>(bool isAsc,
            Expression<Func<T, S>> orderLambda, Expression<Func<T, bool>> whereLambda);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <typeparam name="S"></typeparam>
        /// <param name="page"></param>
        /// <param name="sizie"></param>
        /// <param name="isAsc"></param>
        /// <param name="orderLambda"></param>
        /// <param name="whereLambda"></param>
        /// <returns></returns>
        Task<(List<T> list, int count)> GetListByPageAsync<S>(int page, int sizie, bool isAsc,
            Expression<Func<T, S>> orderLambda, Expression<Func<T, bool>> whereLambda);

        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> AddAsync(T t);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync(T t);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> DeleteAsync(T t);

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ts"></param>
        /// <returns></returns>
        Task<bool> DeleteRangeAsync(T[] ts);
    }
}
